package com.banan.Interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 *描述（修改后直接追加）：
 *拦截器 做双写操作
 * @author liuqiang
 * @date  2016年7月7日 
 *
 **/
public class SpringInterceptor implements HandlerInterceptor {

	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object object, Exception exception)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

	/**
	 * 请求完成后 拦截操作
	 */
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1,
			Object arg2, ModelAndView arg3) throws Exception {
		System.out.println("*****************出拦截操作*****************");
	}

	/**
	 * 返回true 开启postHandle
	 * 返回false  关闭postHandle  只执行preHandle
	 */
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
			Object object) throws Exception {
		//从redis中获取 是否开起拦截
		System.out.println("*****************进入拦截操作*****************");
		boolean boo=true;
		if(boo){
			return boo;
		}
		
		return false;
	}

}
